package com.foreknow.demo5;

/**
 * 定义三个方法：getArea()求面积、getPer()求周长，showAll()分别在控制台输出长、宽、面积、周长。
 */
public class Rectangle {
    private int length;
    private int width;

    public Rectangle() {

    }

    public Rectangle(int length,int width) {
        this.length = length;
        this.width = width;
    }

    public int getArea(){
        return length * width;
    }

    public int getPer(){
        return 2 * (length + width);
    }

    public void showAll(){
        System.out.println("长: "+length+"宽: "+width+"面积: "+getArea()+"周长 "+getPer());
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle(2,3);
        rectangle.showAll();
    }
}
